package com.heima.search.util;

import com.heima.model.user.entity.ApUser;

public class AppUserThreadLocalUtil {

    private static final ThreadLocal<ApUser> TL = new ThreadLocal();

    /**
     * 保存用户信息到ThreadLocal
     *
     * @param apUser
     */
    public static void set(ApUser apUser) {
        if (apUser != null) {
            TL.set(apUser);
        }
    }


    /**
     * 从ThreadLocal获取用户信息
     *
     * @return
     */
    public static ApUser get() {
        return TL.get();
    }

    /**
     * 从ThreadLocal获取用户信息
     *
     * @return
     */
    public static void remove() {
        TL.remove();
    }


}
